package com.ysh.gsm;

import java.io.Serializable;
import java.util.Arrays;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.FetchType;
import javax.persistence.Id;

import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;



/**
 * @author ysh
 *
 */
@Embeddable
public class CdrPK implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -1696794223722616829L;
	
	private Callleg callLeg;
	private short sequence;
	
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "callleg_id", referencedColumnName = "callleg_id", nullable = false, insertable = false, updatable = false)
	public Callleg getCallLeg() {
		return callLeg;
	}
	public void setCallLeg(Callleg callLeg) {
		this.callLeg = callLeg;
	}
	@Id	
	@Column(name = "sequence", nullable = false)
	public short getSequence() {
		return sequence;
	}
	
	public void setSequence(short sequence) {
		this.sequence = sequence;
	}
	
	public CdrPK() {
		super();
	}
	public int hashCode() {
		 return Arrays.hashCode(new Object[] {
				 callLeg, sequence 
			    });
	}

	public boolean equals(Object obj) {
		if (obj == this) {
			return true;
		}
		if (!(obj instanceof CdrPK)) {
			return false;
		}
		if (null == obj) {
			return false;
		}
		CdrPK pk = (CdrPK) obj;
		return (pk.callLeg == callLeg && pk.sequence == sequence);
	}
	

}
